<template>
    <div class="login">
        <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
            <el-form-item label="用户名" prop="name">
                <el-input type="text" v-model="ruleForm2.name" auto-complete="off"></el-input>
            </el-form-item>

            <el-form-item label="密码" prop="pass">
                <el-input type="password" v-model="ruleForm2.pass" auto-complete="off"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="submitForm('ruleForm2')">提交</el-button>
                <el-button @click="resetForm('ruleForm2')">重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import MenuUtils from "../util/rotlist";
import t404 from '../views/404'
import rout from '../views/roubalde'

var routers = [];
export default {
    data() {
        return {
            ruleForm2: {
                pass: 'admin',
                name: '123456',
            },
            rules2: {
                name: [
                    { required: 'true', message: "请输入账号", trigger: 'blur' },

                ],
                pass: [
                    { required: true, message: "请输入密码", trigger: 'blur' }
                ]

            }
        };
    },
    methods: {
        submitForm(formName) {
            var _this = this;
            this.$refs[formName].validate((valid) => {
                if (valid) {

                    let loginParams = { loginName: this.ruleForm2.name, password: this.ruleForm2.pass }
                    console.log((resolve) => require(['../views/404.vue'], resolve))
                    var falseData = [{
                        path: '/home',
                        name: 'home',
                        component: 'home',
                        leaf: false,
                        children: [{
                            path: '/routy',
                            component: 'roubalde',
                            name: '角色权限rouyt',
                            leaf: true,
                        }, {
                            path: '/rou',
                            component: '404',//文件名称
                            name: '角色权限rouyt',
                            leaf: true,
                        }]
                    }, {
                        path: '/505',
                        component: '505',
                        name: '角色权限rouyt',
                        leaf: true,
                         children: []
                    }, {
                        path: '*',
                        hidden: true,
                        redirect: '/t404'
                    }]

                    sessionStorage.setItem('menus', JSON.stringify(falseData))
                    MenuUtils(routers, falseData);
                    this.$router.addRoutes(routers);

                    this.$router.push('/home')
                    this.menus = JSON.parse(sessionStorage.getItem('menus'));


                }
            });
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        },

    }
}
</script>
<style  scoped>
html,
body {
    background-color: red
}

.login {
    background-color: #ededed;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.login>.el-form {
    width: 600px;
    margin: 200px auto
}
</style>


